import {defineStore} from 'pinia'

export const useCacheStore = defineStore('cache', {
    state: () => {
        return {
            chattingCache: new Map(),
        }
    },
    getters: {},
    actions: {
        addChatCache(id, data) {
            this.chattingCache.set(id, data)
        },
        clearChatCache() {
            this.chattingCache.clear()
        },
        getChatCache(id) {
            return this.chattingCache.get(id) || null
        }
    },
    // 设置什么方式持久化
    persist: {
        storage: sessionStorage,
        paths: ['cacheChatting'],
    },   
})